package org.grayrabbit.cms.security;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class PermissionHelper {
	static final Logger logger = LoggerFactory.getLogger(PermissionHelper.class);;
	private static Map<String,String> uriOperCodeMap = new HashMap<String, String>();
	static{
		Properties prop = new Properties();
		try {
			prop.load(PermissionHelper.class.getResourceAsStream("/permission.properties"));
			for(Object key : prop.keySet()) {
				Object value = prop.get(key);
				uriOperCodeMap.put((String) key, (String) value);
			}
		} catch (IOException e) {
			logger.error("读取uri权限配置文件出错",e);
		}
	}
	
	public static String get(String uri){
		return uriOperCodeMap.get(uri);
	}
	public static boolean exist(String uri){
		return uriOperCodeMap.containsKey(uri);
	}
}
